package com.jy.admin.db.dao.impl;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.jy.admin.db.dao.OpdCsvExpandDao;
import com.jy.admin.db.entity.OpdCsvExpandEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: anonymous
 * Date: 2021-11-27
 * Time: 00:27:10.574
 */

@Repository
public class OpdCsvExpandDaoImpl extends AbstractBaseMapper<OpdCsvExpandEntity> implements OpdCsvExpandDao {

    //    insert into user (id, username, password, email, created_at, updated_at) values (1, 'benett123', md5('123456'), '123456@163.com', current_date(), current_date()) ON DUPLICATE KEY UPDATE username='xiaoming';
    @Override
    public void saveBatchMobile(String merchantCode, String dataNo, List<String> mobiles) {
        Map<String, Object> params = new HashMap<>();
        params.put("merchantCode", merchantCode);
        params.put("dataNo", dataNo);
        params.put("mobiles", mobiles);
        getSqlSession().insert(this.getStatement("saveBatchMobile"), params);
    }

    @Override
    public void updateDndStatus(String merchantCode, String dataNo, List<String> dndMobiles,Integer isDnd) {
        Map<String, Object> params = new HashMap<>();
        params.put("merchantCode", merchantCode);
        params.put("dataNo", dataNo);
        params.put("dndMobiles", dndMobiles);
        params.put("isDnd", isDnd);
        getSqlSession().insert(this.getStatement("addBatchDndTag"), params);
    }

    @Override
    public List<OpdCsvExpandEntity> getListByDataNoAndDndStatus(String dataNo, int isDnd, Page page) {
        Map<String, Object> params = new HashMap<>();
        params.put("dataNo", dataNo);
        params.put("isDnd", isDnd);
        params.put("page", page);
        return getSqlSession().selectList(this.getStatement("getListByDataNoAndDndStatus"), params);
    }

    @Override
    public List<OpdCsvExpandEntity> getNeedCheckDndListByDataNo(String dataNo, Page page) {
        Map<String, Object> params = new HashMap<>();
        params.put("dataNo", dataNo);
        params.put("page", page);
        return getSqlSession().selectList(this.getStatement("getNeedCheckDndListByDataNo"), params);
    }

    @Override
    public int getDndCntByDataNo(String dataNo) {
        Map<String, Object> params = new HashMap<>();
        params.put("dataNo", dataNo);
        return getSqlSession().selectOne(this.getStatement("getDndCntByDataNo"),params);
    }
}